$('.up').click(function(){
	var answer_id = $(this).attr('data-answer');
	var only = $(this);
	var next = $(this).parent().next('.answer-head').find('.js-voteCount');
	var count = $(this).find('.count').html();
	var count = parseInt(count);
	$.get('/dealpraise', {answer_id:answer_id}, function(data){
		if (data === '0') {
			return false;
		} else if (data === '1'){
			count = count - 1;
			only.find('.count').html(count);
			next.html(count);
		} else if (data === '2') {
			count = count +1;
			only.find('.count').html(count);
			next.html(count);
		} else if (data === '3') {
			count = count +1;
			only.find('.count').html(count);
			next.html(count);
		}
	});
})

$('.down').click(function(){
	var answer_id = $(this).attr('data-answer');
	var only = $(this).prev('.up');
	var next = $(this).parent().next('.answer-head').find('.js-voteCount');
	var count = only.find('.count').html();
	var count = parseInt(count);
	$.get('/opisit', {answer_id:answer_id}, function(data){
		if (data === '2') {
			count = count - 1;
			only.find('.count').html(count);
			next.html(count);
		}
	})
})